package controllers;

//import java.util.Date;

import model.IMaster;
import model.IOrder;
//import database.DataBase;
import database.IDataBase;

public class Autoservice implements IAutoService {

	private IDataBase base;
	private SortController sortController = new SortController();

	public Autoservice(IDataBase base) {

		this.base = base;

	}

	public void listOrdersSortByFilingDate() {
		IOrder[] orders = base.getOrders();

		sortController.sortOrderByFillingDate(orders);

		for (int i = 0; i < orders.length; i++) {
			orders[i].printInfoAboutOrder();
		}
	}

	@Override
	public void listOrdersSortByPerfomanceDate() {
		IOrder[] orders = base.getOrders();

		sortController.sortByPerfomanceDate(orders);

		for (int i = 0; i < orders.length; i++) {
			orders[i].printInfoAboutOrder();
		}

	}
	
	
	public void listOrdersSortByPlannedStartDate() {
		IOrder[] orders = base.getOrders();

		sortController.sortByPlannedStartDate(orders);

		for (int i = 0; i < orders.length; i++) {
			orders[i].printInfoAboutOrder();
		}

	}

	public void listOrdersSortByPrice() {
		IOrder[] orders = base.getOrders();

		sortController.sortByPrice(orders);

		for (int i = 0; i < orders.length; i++) {
			orders[i].printInfoAboutOrder();
		}

	}
	
	
	public void listMasterSortByName() {
		IMaster[] masters = base.getMasters();
		sortController.sortByName(masters);
		for (int i = 0; i < masters.length; i++) {
			masters[i].printInfoAboutMaster();
		}
	}


}
